package com.blockmeta.bbs.immodule.widget.msgview;

import android.content.Context;
import android.widget.ImageView;

import com.blockmeta.bbs.baselibrary.utils.LoadPicUtil;
import com.blockmeta.bbs.baselibrary.utils.OpenFileUtil;
import com.blockmeta.bbs.immodule.R;
import com.blockmeta.bbs.immodule.dao.ChatMessage;
import com.chad.library.adapter.base.BaseViewHolder;

public class ImageMsgView<T extends ChatMessage> extends MsgView<T>{

    public ImageMsgView(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.im_chat_image;
    }

    @Override
    public void convert(BaseViewHolder helper, T item, T lastItem) {
        super.convert(helper, item, lastItem);
        bindCommonControl(helper, item, lastItem);

        //发送消息！
        if (item.getType() == ChatMessage.TYPE_SEND) {
            ImageView sendPic = helper.getView(R.id.right_pic);
            setImageSize(sendPic, item);
            LoadPicUtil.loadWithSourceStrategy(item.getFilePath(),sendPic);
            helper.addOnClickListener(R.id.right_pic);
            helper.addOnLongClickListener(R.id.right_pic);

        } else {
            //接收消息
            ImageView receivePic = helper.getView(R.id.left_pic);
            setImageSize(receivePic, item);
            LoadPicUtil.loadWithSourceStrategy(item.getFilePath(),receivePic);
            helper.addOnClickListener(R.id.left_pic);
            helper.addOnLongClickListener(R.id.left_pic);
        }
    }


}
